package com.sanyue.dataStructure.Sort;

import java.util.Arrays;

/**
 * @author sanyue
 * @version 1.0
 * @description: TODO-插入排序
 * @date 2022/1/25 下午5:25
 */
public class Insertion<T extends Comparable<T>> extends Sort {
    @Override
    public void sort(Comparable[] nums) {
        int N = nums.length;
        for (int i = 1; i < N; i++) {
            for (int j = i; j > 0 && less(nums[j], nums[j - 1]); j--) {
                swap(nums, j, j - 1);
            }
            System.out.println("第"+(i)+"次后："+ Arrays.toString(nums));
        }
    }
}
